<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .father{
      width: 500px;
      height: 300px;
      background: #ccc;
      overflow: hidden;
    }
    .son{
      width: 100px;
      height: 100px;
      background: red;
      margin-left: 50%;
      margin-top: 50%;
    }
  </style>
</head>
<body>
  <div class="father">
    <div class="son"></div>
  </div>
</body>
</html>
<!-- 
  margin/padding:四个方向写百分比，那么都是相对于宽度的百分比
 -->